Completed
Pull Request — develop (#230)
by
unknown
04:34 queued 02:20
created

script.js ➔ getCookieValue   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 10
rs 9.4285
1
/* globals Cookies */
2
3
import 'file-loader?name=vendor/js-cookie.js!js-cookie/src/js.cookie'
4
5
export function getOptions (optionContainer) {
0 ignored issues
show
Unused Code introduced by
The parameter optionContainer is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
6
  return {
7
    expireDays: 7,
8
    cookieName: 'cookies_accepted'
9
  }
10
}
11
12
export function acceptCookies ($container, cookieName, expireDays) {
13
  return function (e) {
0 ignored issues
show
Unused Code introduced by
The parameter e is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
14
    Cookies.set(cookieName, true, {
15
      expires: expireDays
16
    })
17
18
    $container.remove()
19
  }
20
}
21
22
export function checkCookies ($container, cookieName) {
23
  const cookiesAccepted = getCookieValue(cookieName)
24
25
  if (!cookiesAccepted) {
26
    $container.addClass('cookieNotification-isVisible')
27
  } else {
28
    $container.remove()
29
  }
30
}
31
32
function getCookieValue (cookie) {
33
  const value = '; ' + document.cookie
34
  const parts = value.split('; ' + cookie + '=')
35
36
  if (parts.length === 2) {
37
    return parts.pop().split(';').shift()
38
  } else {
39
    return false
40
  }
41
}
42